package com.xiangwei.util;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.xiangwei.view.EchartsView;
import com.xiangwei.view.SeriesView;

public class BarCharts {
	public static EchartsView barOptionCombined(Map<String,String> title,Map<String, String[]> legend,
			Map<String, Object> xAxis,List<SeriesView> svList) {

		EchartsView ehv = new EchartsView();

		Map<String, String> tooltip = new HashMap<String, String>();
		tooltip.put("trigger", "axit");
		
		Map<String, Object> toolbox = new HashMap<String, Object>();
		toolbox.put("show", true);
		toolbox.put("orient", "vertical");
		toolbox.put("x", "right");
		toolbox.put("y", "center");
		Map<String, Object> mark = new HashMap<String, Object>();
		mark.put("show", true);
		Map<String, Object> dataView = new HashMap<String, Object>();
		dataView.put("show", true);
		dataView.put("readOnly", false);
		Map<String, Object> magicType = new HashMap<String, Object>();
		magicType.put("show", true);
		String[] type = { "line", "bar" };
		magicType.put("type", type);
		Map<String, Object> restore = new HashMap<String, Object>();
		restore.put("show", true);
		Map<String, Object> saveAsImage = new HashMap<String, Object>();
		saveAsImage.put("show", true);
		Map<String, Object> feature = new HashMap<String, Object>();
		feature.put("mark", mark);
		feature.put("dataView", dataView);
		feature.put("magicType", magicType);
		feature.put("restore", restore);
		feature.put("saveAsImage", saveAsImage);
		toolbox.put("feature", feature);

		xAxis.put("type", "category");

		Map<String, Object> yAxis = new HashMap<String, Object>();
		yAxis.put("type", "value");// Y列名
		
		ehv.setTitle(title);
		ehv.setLegend(legend);
		ehv.setToolbox(toolbox);
		ehv.setTooltip(tooltip);
		ehv.setXAxis(xAxis);
		ehv.setYAxis(yAxis);
		ehv.setCalculable(false);
		ehv.setSeries(svList);
		
		return ehv;
	}
}
